//
//  ShellRateCell.m
//  ShellWallert
//
//  Created by lvzhao on 2019/9/27.
//  Copyright © 2019年 VV. All rights reserved.
//

#import "ShellRateCell.h"
#import "ShellRateModel.h"


@interface ShellRateCell()

//货币
@property (nonatomic,strong) UILabel *currencyLab;

//titlelabel 买入卖出
@property (nonatomic,strong) NSMutableArray *titleLabels;

@end

@implementation ShellRateCell



- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.backgroundColor = COLOR_BACKGROUND;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.accessoryType  = UITableViewCellAccessoryNone;
        [self setupView];
    }
    return self;
}


#pragma mark - setupView
- (void)setupView{

    //货币
    [self.contentView addSubview:self.currencyLab];
    [self.currencyLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.left.mas_equalTo(10);
        make.width.mas_equalTo(63);
        make.height.mas_equalTo(self.contentView);
    }];
    
 
    CGFloat titleW = (K_SCREENWIDTH - 73)/4.0;
    for(int i = 0; i < 4; i++){
        
        UILabel *titleLabe = [UILabel lz_createLabWithTextColor:UIColorHex(0xFFFFFF) font:k_textFont(13)];
        [titleLabe lz_centerAlignment];
        [self.contentView addSubview:titleLabe];
        [titleLabe mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.contentView.mas_centerY);
            make.left.mas_equalTo(self.currencyLab.mas_right).mas_equalTo(i * titleW);
            make.width.mas_equalTo(titleW);
            make.height.mas_equalTo(self.contentView);
        }];
        
        [self.titleLabels addObject:titleLabe];
    }
   
    
    
    
}


#pragma mark - actions

#pragma mark - custool

#pragma mark - get && set
- (void)setModelObject:(id)modelObject{
    ShellRateModel *rateModel = modelObject;
    self.currencyLab.text = rateModel.name;

    if(self.indexPath.row % 2 == 0){
        self.backgroundColor = COLOR_BACKGROUND;
        self.currencyLab.textColor = UIColorHex(0xFFFFFF);
    } else {
        self.backgroundColor = UIColorHex(0x031D32);
        self.currencyLab.textColor = UIColorHex(0x6699BF);

    }
    NSString *fbuyPrice = [NSString stringWithFormat:@"%f",rateModel.fbuyPrice].saveDecimal;
    NSString *fsellPrice = [NSString stringWithFormat:@"%f",rateModel.fsellPrice].saveDecimal;
    NSString *mbuyPrice = [NSString stringWithFormat:@"%f",rateModel.mbuyPrice].saveDecimal;
    NSString *msellPrice = [NSString stringWithFormat:@"%f",rateModel.msellPrice].saveDecimal;

    NSArray *titles = @[fbuyPrice,fsellPrice,mbuyPrice,msellPrice];
    for(int i = 0; i < self.titleLabels.count; i++){
        UILabel *titleLab = self.titleLabels[i];
        titleLab.text = titles[i];
        if(self.indexPath.row % 2 == 0){
            titleLab.textColor = UIColorHex(0xFFFFFF);
        } else {
            titleLab.textColor = UIColorHex(0x6699BF);
        }
    }
}


//货币
- (UILabel *)currencyLab{
    if(!_currencyLab){
        _currencyLab = [UILabel lz_createLabWithTextColor:UIColorHex(0xFFFFFF) font:k_textFont(13)];
    }
    return _currencyLab;
}

- (NSMutableArray *)titleLabels{
    if(!_titleLabels){
        _titleLabels = [NSMutableArray arrayWithCapacity:0];
    }
    return _titleLabels;
}


@end
